const gulp = require('gulp');
const rename = require('gulp-rename');
const htmlmin = require('gulp-htmlmin');
const uglify = require('gulp-uglify');
const imagemin = require('gulp-imagemin');
const path = require('path');




gulp.task('htmlmin', function() {
    return gulp.src('./src/html/*.html')
        .pipe(htmlmin({ collapseWhitespace: true }))
        .pipe(gulp.dest('./src/html'))
})

gulp.task('uglify', function() {
    return gulp.src(['./src/js/*.js', '!./src/js/*.min.js'])
        .pipe(uglify())
        .pipe(rename({ suffix: '.min' }))
        .pipe(gulp.dest('./src/dist/js'))
})

gulp.task('imagemin', function() {
    return gulp.src(['./src/img/*.jpg', './src/img/*.png'])
        .pipe(imagemin())
        .pipe(gulp.dest('./src/dist/img'))
})
gulp.task('watch', function() {
    gulp.watch(['./src/html/*.html', './src/css/*.css', './src/js/*.js', gulp.series('htmlmin', 'cssmin', 'js')])
})